using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class JobSeekers_resume : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    
        if (Session.Contents["jsuserid"] == null)
        {
            Response.Redirect("login.aspx");
        }
        else
        {
            txtContactEmail.Text = Convert.ToString(Session["jsemail"]);
            string resumeID = Request.QueryString.Get("ResumeID");
            if (!IsPostBack)
                EditResume(resumeID);
        }
        
    }
    void EditResume(string resumeID)
    {
        if (resumeID != "")
        {
            SQLServerProviders cls = new SQLServerProviders();
            DataTable dataTable =
            cls.GetDataTable("select ResumeID,"+
            " UserID,ResumeTitle,ContactEmail, "+
            "Objective,ExperienceYear,"+
            "CurrentCompany,Viewable,"+
            "Confidental, TemplateResume "+
            " from tblJSResumes" +
            " where UserID='" + Session["jsuserid"] +
             "' and ResumeID='" + resumeID
             + "'", CommandType.Text);
             if(dataTable.Rows.Count>0)
            {
                ResumeID.Value = dataTable.Rows[0][0].ToString();            
                txtJob.Text=dataTable.Rows[0][2].ToString();
                txtContactEmail.Text=dataTable.Rows[0][3].ToString();
                txtObjective.Text=dataTable.Rows[0][4].ToString();
                ddlExperienceYear.SelectedValue=dataTable.Rows[0][5].ToString();
                txtCurrentCompany.Text=dataTable.Rows[0][6].ToString();
                ddlViewable.SelectedValue=dataTable.Rows[0][7].ToString();
                ddlTemplate.SelectedValue=dataTable.Rows[0][9].ToString();
                if (dataTable.Rows[0][8].ToString()=="True")
                    rdbConfidential.Checked =  true ;
                else
                    rdbNotConfidential.Checked = true;
            }
        }
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        SQLServerProviders cls = new SQLServerProviders();
        string returnValue = cls.AddNewUpdateResume(
        ((ResumeID.Value != "") ? ResumeID.Value : "0"),
        Convert.ToString(Session.Contents["jsuserid"]),
        txtJob.Text, txtContactEmail.Text,
        txtObjective.Text,
        ddlExperienceYear.SelectedValue,
        txtCurrentCompany.Text,
        ddlViewable.SelectedValue,
        ddlTemplate.SelectedValue,
        rdbConfidential.Checked);
        if (cls.ErrorMessage!="")            
            literalError.Text = "Error: " + cls.ErrorMessage;
        else
            {
            if(ResumeID.Value!="")
                Session["ResumeID"] = ResumeID.Value;
            else
                Session["ResumeID"]= returnValue;
            Response.Redirect("resumedetails.aspx");
            }
    }
}
